package com.sia.springcloud;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: Sirius
 * @Date: 2021/12/27 17:00
 * @Description:
 **/
@EnableEurekaClient
@SpringBootApplication
@ServletComponentScan  //@ServletComponentScan:作用让SpringBoot扫描@WebServlet等注解
@MapperScan("com.sia.springcloud.mapper") // @MapperScan：作用是用于扫描MyBatis的mapper接口的包
public class DataProcessApplication {


    @Bean //将返回的RestTemplate对象注入到IOC容器中
    @LoadBalanced //对RestTemplate进行负载均衡
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
        simpleClientHttpRequestFactory.setConnectTimeout(60000);
        simpleClientHttpRequestFactory.setReadTimeout(60000);
        return new RestTemplate(simpleClientHttpRequestFactory);
    }


    public static void main(String[] args) {
        SpringApplication.run(DataProcessApplication.class, args);
    }
}
